Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

check-error

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-error

Error comparison and information related utility for node and the browser

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is check-error?

The check-error npm package is a utility for checking errors and their properties. It is primarily used for testing error conditions in a consistent and readable manner. It provides functions to validate the type of an error, its message, and other properties.

What are check-error's main functionalities?

check error type

This feature allows you to check if an error is of a specific type, such as TypeError, using the isTypeError method.

const checkError = require('check-error');
const TypeError = checkError.TypeError;
try {
  // some code that may throw
} catch (e) {
  if (checkError.isTypeError(e)) {
    // handle TypeError specifically
  }
}

check error instance

This feature allows you to check if an error is an instance of a specific error class using the instanceOf method.

const checkError = require('check-error');
try {
  // some code that may throw
} catch (e) {
  if (checkError.instanceOf(e, CustomError)) {
    // handle CustomError specifically
  }
}

check error message

This feature allows you to check if an error contains a specific message using the hasMessage method.

const checkError = require('check-error');
try {
  // some code that may throw
} catch (e) {
  if (checkError.hasMessage(e, 'expected message')) {
    // handle errors with a specific message
  }
}

Other packages similar to check-error

Keywords

FAQs

Package last updated on 08 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc